#include "app.h"
#include <stdio.h>
#include "pad.h"
#include "umstr.h"

#include "app.h"
#include "state.h"
#include "bsp.h"
#include "app_data.h"

#include "uart.h"

//---------------------------------------------
typedef void (*GreenLed_Guid)(u8 on);

void Fn_Null_Guid(u8 on){}

static GreenLed_Guid   greenLed_Guid[16] =
{
		Fn_Null_Guid,
		Fiber250W_Guid,
		Fn_Null_Guid,
		RLaser_Guid,
		Fn_Null_Guid,
		MFSC_500W_Guid,
		SPTLaser_Guid,
		Fn_Null_Guid,
		RLaser_Guid,
		RLaser_Guid,
		RLaser_Guid,
		Fn_Null_Guid,
		RLaser_Guid,
		Fn_Null_Guid,
		Fn_Null_Guid,
		Fn_Null_Guid
};
//----------------------------------------------

void _process_null()   // 0
{ // 0
}

void _process_green_led() //1
{
	u16 param = 0;
	//BSP_GreenLED(PAD_RxData.param2);

	greenLed_Guid[bsp_address](PAD_RxData.param2);

	u8 index = can_msg.num;
	if ( can_msg.num < CAN_MESS_MAX_SIZE-1 )
	{
		can_msg.msg[index].id = 3;
		can_msg.msg[index].len = 2;
		can_msg.msg[index].sbuf[0] = CMD_LASER_GREEN;
		can_msg.msg[index].sbuf[1] = PAD_RxData.param2;
		can_msg.num++;
	}

    param = PAD_RxData.param2==0?1:0;
    Response2PAD(PAD_RxData.param1, param);


}
void _process_laser()  //2
{
	if ( protect.EN_PAD_ENABLE == 0 &&  PAD_RxData.param2 == 1 )
	{
		BSP_LaserEnable(1);
	}

    BSP_Laser(PAD_RxData.param2);
}

void _process_set_focal()  //10
{
	spt.focal_index = PAD_RxData.param2;
}

int App_GetSpeed()
{
	g_pad.speed = motor_spd[spd.mode][spd.spd[spd.mode]];
	return g_pad.speed;
}


pad_process App_PAD_Process[App_PAD_Process_MAX_NUM]=
{
    _process_null,      // 0
    _process_green_led, // 1
    _process_laser,
    _process_focal,
    _process_focal_val,
    _process_set_A_B,

    _process_line,     // 6
    _process_go,
    _process_stop,
    _process_set_power,
    _process_set_focal,

    _process_set_spd, //11
    _process_line2,
    _process_poll_sd007a,
    _process_set_protective_fence_mode,   //14
    _process_set_protective_fence_params,

    _process_set_ab_loop_mode,   //16
    _process_reset_ab,     //17
    _process_set_xy_limit_pls, //18
//    _process_null
};

